#include <iostream>
#include "Threadpool.hpp"
#include <memory>
#include <string>
#include "Log.hpp"
#include "Task.hpp"
#include <ctime>


int main()
{
    // EnableFile();
    EnableScreen();
    srand(time(nullptr) ^ getpid() ^ pthread_self());
    std::unique_ptr<ThreadPool<Task>> tp = std::make_unique<ThreadPool<Task>>(5);
    tp->InitThreadPool();
    tp->Start();
    int tasknum = 10;
    while (tasknum)
    {
        int a = rand() % 10 + 1;
        usleep(1234);
        int b = rand() % 5 + 1;
        Task t(a, b);
        LOG(INFO, "main thread push task: %s", t.DebugToString().c_str());
        tp->Enqueue(t);
        sleep(1);
        tasknum--;
    }
    // EnableScreen();
    sleep(5);
    tp->Stop();
    tp->Wait();

    // LogMessage(__FILE__, __LINE__, DEBUG, "hello world");
    // LogMessage(__FILE__, __LINE__, DEBUG, "hello world %d",10);
    // LogMessage(__FILE__, __LINE__, DEBUG, "hello world %d %s",10,"hello");
    // LogMessage(__FILE__, __LINE__, DEBUG, "hello world %d %s %f",10,"hello",3.14);

    // EnableFile();
    // LOG(DEBUG, "hello world %d %s %f", 10, "hello", 3.14f);
    // LOG(DEBUG, "hello world %d %s", 10, "hello");
    // LOG(DEBUG,"hello world %d %s %f", 10, "hello", 3.14);

    return 0;
}